package algorithm.poj.p2000;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLDecoder;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;


/**
 * 分析：
 * 
 * 实现：
 * 
 * 经验：
 * 
 * 教训：
 * 
 * @author wong.tong@gmail.com
 *
 */
public class P2002 {

	public static void main(String[] args) throws Exception {

		InputStream input = null;
		if (false) {
			input = System.in;
		} else {
			URL url = P2002.class.getResource("P2002.txt");
			File file = new File(URLDecoder.decode(url.getPath(), "UTF-8"));
			input = new FileInputStream(file);
		}
		
		BufferedReader stdin = new BufferedReader(new InputStreamReader(input));
		
		String line = stdin.readLine();
		while (line != null && !"0".equals(line.trim())) {
			int n = Integer.valueOf(line);
			Point[] points = new Point[n];
			Set<Point> set = new HashSet<Point>();
			for (int i = 0; i < n; i ++) {
				line = stdin.readLine();
				StringTokenizer st = new StringTokenizer(line);
				points[i] = new Point();
				points[i].x = Integer.valueOf(st.nextToken());
				points[i].y = Integer.valueOf(st.nextToken());
				set.add(points[i]);
			}
			int count = 0;
			for (int i = 0; i < n; i ++) {
				for (int j = 0; j < i; j ++) {
					if (check(points[i], points[j], set)) {
						count ++;
					}
					if (check(points[j], points[i], set)) {
						count ++;
					}
				}
			}
			System.out.println(count/4);
			line = stdin.readLine();
		}
	}
	
	private static boolean check(Point p1, Point p2, Set<Point> points) {
		
		Point p3 = new Point();
		p3.x = p1.x - (p2.y-p1.y);
		p3.y = p2.x - p1.x + p1.y;
		
		if (points.contains(p3)) {
			Point p4 = new Point();
			p4.x = p2.x - (p2.y-p1.y);
			p4.y = p2.x - p1.x + p2.y;
			if (points.contains(p4)) { 
				return true;
			}
		}
		return false;
	}
	
	private static class Point {
		
		int x;
		int y;
		
		@Override
		public int hashCode() {
			return (x<<12) + (x<<1) + x + y;
		}
		
		@Override
		public boolean equals(Object o) {
			if (o == null || !(o instanceof Point)) {
				return false;
			} else {
				Point p = (Point)o;
				return p.x == this.x && p.y == this.y;
			}
		}
	}

	
}
